#include <iostream>
#include <cstring>
#include <algorithm>
#include <queue>

using namespace std;

typedef pair<int, int> PII;

const int N = 1e5 + 10;

priority_queue<PII> heap;

int a[N], b[N];
int n, m;


int main()
{
    cin >> n >> m;
    
    for(int i = 1; i <= n; i ++){
        cin >> a[i] >> b[i];
        heap.push({a[i], i});
    }
    
    int ans = 0;
    for(int i = 1; i <= m; i ++){
        ans += heap.top().first;
        int k = heap.top().second;
        heap.pop();
        a[k] -= b[k];
        heap.push({a[k], k});
    }
    
    cout << ans << endl;
    
    return 0;
}

